import request from '@/utils/request'

export function getAll(params) {
  return request({
    url: '/device',
    method: 'get',
    params
  })
}

export function getOne(serialno) {
  return request({
    url: '/device/' + serialno,
    method: 'get'
  })
}

export function addOne(data) {
  return request({
    url: '/device',
    method: 'post',
    data
  })
}

export function updateOne(id, data) {
  return request({
    url: '/device/' + id,
    method: 'put',
    data
  })
}

export function deleteOne(id) {
  return request({
    url: '/device/' + id,
    method: 'delete'
  })
}

export function sendCommand(data, serialno) {
  return request({
    url: '/device/' + serialno + '/sendCommand',
    method: 'post',
    data
  })
}

export function sendCommands(data, serialno) {
  return request({
    url: '/device/' + serialno + '/sendCommands',
    method: 'post',
    data
  })
}

export function sendPWM(data) {
  return request({
    url: '/device/pwm',
    method: 'post',
    data
  })
}

export function getDevicesStates(data) {
  return request({
    url: `/devices/states`,
    method: 'post',
		data
  })
}

export function getDeviceStates(serialno) {
  return request({
    url: `/devices/states/${serialno}`,
    method: 'get'
  })
}

export function selectForCloud(params) {
  return request({
    url: '/device/select/cloud',
    method: 'get',
    params
  })
}

export function selectOneForCloud(serialno) {
	return request({
	  url: `/device/select/${serialno}/cloud`,
	  method: 'get'
	})
}

export function getFullSerialnoBySerialno(serialno) {
	return request({
	  url: `/device/select/${serialno}/serialno`,
	  method: 'get'
	}) 
}

export function restartGw(serialno) {
  return request({
    url: `/device/restartGw/${serialno}`,
    method: 'get'
  })
}

export function getGwNumber(sn) {
  return request({
    url: `/device/gw/number`,
    method: 'get',
		params:{sn}
  })
}

export function getRtuIds(sn,ch) {
  return request({
    url: `/device/rtus/number`,
    method: 'get',
		params:{sn,ch}
  })
}

export function getAeskeys(params) {
  return request({
    url: `/device/aeskeys/number`,
    method: 'get',
		params
  })
}
